bitkeeper revision 1.48 (3e4e7b09RoRhdqgVpx2ahzGbpt_4wg)
authorkaf24@labyrinth.cl.cam.ac.uk <kaf24@labyrinth.cl.cam.ac.uk>
Sat, 15 Feb 2003 17:38:17 +0000 (17:38 +0000)
committerkaf24@labyrinth.cl.cam.ac.uk <kaf24@labyrinth.cl.cam.ac.uk>
Sat, 15 Feb 2003 17:38:17 +0000 (17:38 +0000)
dom0_core.c, domain.c, dom0_ops.c, dom_builder.c:
  Further fixes to domain building

tools/domain_builder/dom_builder.c
xen-2.4.16/common/dom0_ops.c
xen-2.4.16/common/domain.c
xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/dom0_core.c

index 1a9199f2a150b07c76caa44c6bbcab397524afa6..d2df002a675147bff08ac517c8d057015f633379 100644 (file)
@@ -11,6 +11,7 @@
 #include <sys/mman.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <stdlib.h>
 
 #include "hypervisor_defs.h"
 #include "dom0_ops.h"
@@ -25,9 +26,6 @@
 #define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_USER|_PAGE_ACCESSED)
 #define L2_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_USER|_PAGE_ACCESSED|_PAGE_DIRTY)
 
-/* Round _n up to nearest multiple of _m. */
-#define ROUND_UP(_n,_m) (((_n) + (_m) - 1) / (_m))
-
 /* standardized error reporting function */
 static void dberr(char *msg)
 {
@@ -203,7 +201,6 @@ static int do_kernel_chcks(char *image, long dom_size,
                close(fd);
         goto out;
     }
-    *ksize = stat.st_size - SIG_LEN;
     
     read(fd, signature, SIG_LEN);
     if(strncmp(signature, GUEST_SIG, SIG_LEN)){
@@ -216,6 +213,8 @@ static int do_kernel_chcks(char *image, long dom_size,
 
     read(fd, load_addr, sizeof(unsigned long));
 
+    *ksize = stat.st_size - SIG_LEN - sizeof(unsigned long);
+
     sprintf(status, "Kernel image %s valid, kernel virtual load address %lx", 
         image, *load_addr);
     dbstatus(status);
@@ -252,13 +251,16 @@ static dom_meminfo_t *setup_guestos(int dom, int kernel_fd,
     int cmd_fd;
 
     meminfo     = (dom_meminfo_t *)malloc(sizeof(dom_meminfo_t));
-    page_array  = (unsigned long *)dom_mem->vaddr;
+    page_array  = malloc(dom_mem->tot_pages * 4);
     pgt_updates = (page_update_request_t *)dom_mem->vaddr;
     alloc_index = dom_mem->tot_pages - 1;
 
+    memcpy(page_array, (void *)dom_mem->vaddr, dom_mem->tot_pages * 4);
+
     /* Count bottom-level PTs, rounding up. Include one PTE for shared info. */
-    num_pt_pages = ROUND_UP(l1_table_offset(virt_load_addr) +
-                            dom_mem->tot_pages + 1, 1024);
+    num_pt_pages = 
+        (l1_table_offset(virt_load_addr) + dom_mem->tot_pages + 1024) / 1024;
+
     /* We must also count the page directory. */
     num_pt_pages++;
 
@@ -282,9 +284,13 @@ static dom_meminfo_t *setup_guestos(int dom, int kernel_fd,
     pgt_updates++;
     num_pgt_updates++;
 
-    /* Initialise the page tables. */
+    /*
+     * Initialise the page tables. The final iteration is for the shared_info
+     * PTE -- we break out before filling in the entry, as that is done by
+     * Xen during final setup.
+     */
     l2tab += l2_table_offset(virt_load_addr) * sizeof(l2_pgentry_t);
-    for ( count = 0; count < dom_mem->tot_pages; count++ )
+    for ( count = 0; count < (dom_mem->tot_pages + 1); count++ )
     {    
         if ( !((unsigned long)l1tab & (PAGE_SIZE-1)) ) 
         {
@@ -302,6 +308,9 @@ static dom_meminfo_t *setup_guestos(int dom, int kernel_fd,
             num_pgt_updates++;
             l2tab += sizeof(l2_pgentry_t);
         }
+
+        /* The last PTE we consider is filled in later by Xen. */
+        if ( count == dom_mem->tot_pages ) break;
                
         if ( count < pt_start )
         {
@@ -344,7 +353,8 @@ static dom_meminfo_t *setup_guestos(int dom, int kernel_fd,
     close(cmd_fd);
 
     /* Load the guest OS image. */
-    if(!(read(kernel_fd, (char *)dom_mem->vaddr, ksize) > 0)){
+    if( read(kernel_fd, (char *)dom_mem->vaddr, ksize) != ksize )
+    {
         dberr("Error reading kernel image, could not"
               " read the whole image. Terminating.\n");
         goto out;
index c2eae723c09ffd6415ef5d22bbeb7eb535d7b0b6..4d0caaa96a754c37fbf0411c0ef59a27daf30d3f 100644 (file)
@@ -72,8 +72,8 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
     case DOM0_STARTDOM:
     {
         struct task_struct * p = find_domain_by_id(op.u.meminfo.domain);
-        ret = final_setup_guestos(p, &op.u.meminfo);
-        if( ret != 0 ){
+        if ( (ret = final_setup_guestos(p, &op.u.meminfo)) != 0 )
+        {
             p->state = TASK_DYING;
             release_task(p);
             break;
index cb24e0cdce378d394c04c40ef1dccd94971b83e6..3535b45e501434767cf272e52c4878d12b38d39b 100644 (file)
@@ -262,8 +262,8 @@ int final_setup_guestos(struct task_struct * p, dom_meminfo_t * meminfo)
     unmap_domain_mem((void *)((unsigned long)l1tab & PAGE_MASK));
 
     /* set up the shared info structure */
-       update_dom_time(p->shared_info);
-       p->shared_info->cpu_freq         = cpu_freq;
+    update_dom_time(p->shared_info);
+    p->shared_info->cpu_freq    = cpu_freq;
     p->shared_info->domain_time  = 0;
 
     /* we pass start info struct to guest os as function parameter on stack */
index f8a6ea93ea518dba931ac9075968d087689d50f3..0cc35d983260e6f02a0aaa49f4fc4d8fb9c72438 100644 (file)
@@ -194,7 +194,8 @@ static int cmd_write_proc(struct file *file, const char *buffer,
     int ret = 0;
     struct proc_dir_entry * new_dom_id;
     dom0_newdomain_t * params;
-
+    int i;
+    unsigned long p;
     
     copy_from_user(&op, buffer, sizeof(dom0_op_t));
 
@@ -211,8 +212,11 @@ static int cmd_write_proc(struct file *file, const char *buffer,
     }
     else if ( op.cmd == DO_PGUPDATES )
     {
-        ret = HYPERVISOR_pt_update((void *)op.u.pgupdate.pgt_update_arr,
-                                   op.u.pgupdate.num_pgt_updates);
+        p = op.u.pgupdate.pgt_update_arr;
+        for ( i = 0; i < op.u.pgupdate.num_pgt_updates; i++ )
+        {
+            ret = HYPERVISOR_pt_update(p + i*8, 1);
+        }
     }
     else
     {